\(\int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx\) [22]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [B] (verified)
   Fricas [B] (verification not implemented)
   Sympy [F]
   Maxima [F]
   Giac [F(-2)]
   Mupad [F(-1)]

Optimal result

Integrand size = 17, antiderivative size = 89 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{2 \sqrt {b}}-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)} \]

[Out]

arctan(cot(x)*(a-b)^(1/2)/(a+b*cot(x)^2)^(1/2))*(a-b)^(1/2)-1/2*(a-2*b)*arctanh(cot(x)*b^(1/2)/(a+b*cot(x)^2)^
(1/2))/b^(1/2)-1/2*cot(x)*(a+b*cot(x)^2)^(1/2)

Rubi [A] (verified)

Time = 0.15 (sec) , antiderivative size = 89, normalized size of antiderivative = 1.00, number of steps used = 7, number of rules used = 7, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.412, Rules used = {3751, 489, 537, 223, 212, 385, 209} \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{2 \sqrt {b}}-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)} \]

[In]

Int[Cot[x]^2*Sqrt[a + b*Cot[x]^2],x]

[Out]

Sqrt[a - b]*ArcTan[(Sqrt[a - b]*Cot[x])/Sqrt[a + b*Cot[x]^2]] - ((a - 2*b)*ArcTanh[(Sqrt[b]*Cot[x])/Sqrt[a + b
*Cot[x]^2]])/(2*Sqrt[b]) - (Cot[x]*Sqrt[a + b*Cot[x]^2])/2

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 223

Int[1/Sqrt[(a_) + (b_.)*(x_)^2], x_Symbol] :> Subst[Int[1/(1 - b*x^2), x], x, x/Sqrt[a + b*x^2]] /; FreeQ[{a,
b}, x] &&  !GtQ[a, 0]

Rule 385

Int[((a_) + (b_.)*(x_)^(n_))^(p_)/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Subst[Int[1/(c - (b*c - a*d)*x^n), x]
, x, x/(a + b*x^n)^(1/n)] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && EqQ[n*p + 1, 0] && IntegerQ[n]

Rule 489

Int[((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Simp[e^(n - 1
)*(e*x)^(m - n + 1)*(a + b*x^n)^(p + 1)*((c + d*x^n)^q/(b*(m + n*(p + q) + 1))), x] - Dist[e^n/(b*(m + n*(p +
q) + 1)), Int[(e*x)^(m - n)*(a + b*x^n)^p*(c + d*x^n)^(q - 1)*Simp[a*c*(m - n + 1) + (a*d*(m - n + 1) - n*q*(b
*c - a*d))*x^n, x], x], x] /; FreeQ[{a, b, c, d, e, p}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && GtQ[q, 0] &&
GtQ[m - n + 1, 0] && IntBinomialQ[a, b, c, d, e, m, n, p, q, x]

Rule 537

Int[((e_) + (f_.)*(x_)^(n_))/(((a_) + (b_.)*(x_)^(n_))*Sqrt[(c_) + (d_.)*(x_)^(n_)]), x_Symbol] :> Dist[f/b, I
nt[1/Sqrt[c + d*x^n], x], x] + Dist[(b*e - a*f)/b, Int[1/((a + b*x^n)*Sqrt[c + d*x^n]), x], x] /; FreeQ[{a, b,
 c, d, e, f, n}, x]

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = -\text {Subst}\left (\int \frac {x^2 \sqrt {a+b x^2}}{1+x^2} \, dx,x,\cot (x)\right ) \\ & = -\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}+\frac {1}{2} \text {Subst}\left (\int \frac {a+(-a+2 b) x^2}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right ) \\ & = -\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}+(a-b) \text {Subst}\left (\int \frac {1}{\left (1+x^2\right ) \sqrt {a+b x^2}} \, dx,x,\cot (x)\right )+\frac {1}{2} (-a+2 b) \text {Subst}\left (\int \frac {1}{\sqrt {a+b x^2}} \, dx,x,\cot (x)\right ) \\ & = -\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)}+(a-b) \text {Subst}\left (\int \frac {1}{1-(-a+b) x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )+\frac {1}{2} (-a+2 b) \text {Subst}\left (\int \frac {1}{1-b x^2} \, dx,x,\frac {\cot (x)}{\sqrt {a+b \cot ^2(x)}}\right ) \\ & = \sqrt {a-b} \arctan \left (\frac {\sqrt {a-b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )-\frac {(a-2 b) \text {arctanh}\left (\frac {\sqrt {b} \cot (x)}{\sqrt {a+b \cot ^2(x)}}\right )}{2 \sqrt {b}}-\frac {1}{2} \cot (x) \sqrt {a+b \cot ^2(x)} \\ \end{align*}

Mathematica [A] (verified)

Time = 4.41 (sec) , antiderivative size = 140, normalized size of antiderivative = 1.57 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=-\frac {1}{2} \sqrt {\frac {-a-b+a \cos (2 x)-b \cos (2 x)}{-1+\cos (2 x)}} \cot (x)-\frac {\left (2 \sqrt {a-b} \sqrt {b} \arctan \left (\frac {\sqrt {b+a \tan ^2(x)}}{\sqrt {a-b}}\right )+(a-2 b) \text {arctanh}\left (\frac {\sqrt {b+a \tan ^2(x)}}{\sqrt {b}}\right )\right ) \sqrt {a+b \cot ^2(x)} \tan (x)}{2 \sqrt {b} \sqrt {b+a \tan ^2(x)}} \]

[In]

Integrate[Cot[x]^2*Sqrt[a + b*Cot[x]^2],x]

[Out]

-1/2*(Sqrt[(-a - b + a*Cos[2*x] - b*Cos[2*x])/(-1 + Cos[2*x])]*Cot[x]) - ((2*Sqrt[a - b]*Sqrt[b]*ArcTan[Sqrt[b
 + a*Tan[x]^2]/Sqrt[a - b]] + (a - 2*b)*ArcTanh[Sqrt[b + a*Tan[x]^2]/Sqrt[b]])*Sqrt[a + b*Cot[x]^2]*Tan[x])/(2
*Sqrt[b]*Sqrt[b + a*Tan[x]^2])

Maple [B] (verified)

Leaf count of result is larger than twice the leaf count of optimal. \(173\) vs. \(2(71)=142\).

Time = 0.06 (sec) , antiderivative size = 174, normalized size of antiderivative = 1.96

method result size
derivativedivides \(-\frac {\cot \left (x \right ) \sqrt {a +b \cot \left (x \right )^{2}}}{2}-\frac {a \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )}{2 \sqrt {b}}+\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}+\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(174\)
default \(-\frac {\cot \left (x \right ) \sqrt {a +b \cot \left (x \right )^{2}}}{2}-\frac {a \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )}{2 \sqrt {b}}+\sqrt {b}\, \ln \left (\sqrt {b}\, \cot \left (x \right )+\sqrt {a +b \cot \left (x \right )^{2}}\right )-\frac {\sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b \left (a -b \right )}+\frac {a \sqrt {b^{4} \left (a -b \right )}\, \arctan \left (\frac {b^{2} \left (a -b \right ) \cot \left (x \right )}{\sqrt {b^{4} \left (a -b \right )}\, \sqrt {a +b \cot \left (x \right )^{2}}}\right )}{b^{2} \left (a -b \right )}\) \(174\)

[In]

int(cot(x)^2*(a+b*cot(x)^2)^(1/2),x,method=_RETURNVERBOSE)

[Out]

-1/2*cot(x)*(a+b*cot(x)^2)^(1/2)-1/2*a/b^(1/2)*ln(b^(1/2)*cot(x)+(a+b*cot(x)^2)^(1/2))+b^(1/2)*ln(b^(1/2)*cot(
x)+(a+b*cot(x)^2)^(1/2))-(b^4*(a-b))^(1/2)/b/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*cot(x)^2)^(1/2)*cot
(x))+a*(b^4*(a-b))^(1/2)/b^2/(a-b)*arctan(b^2*(a-b)/(b^4*(a-b))^(1/2)/(a+b*cot(x)^2)^(1/2)*cot(x))

Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 187 vs. \(2 (71) = 142\).

Time = 0.31 (sec) , antiderivative size = 768, normalized size of antiderivative = 8.63 \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\left [\frac {2 \, \sqrt {-a + b} b \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) - \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ) \sin \left (2 \, x\right ) - {\left (a - 2 \, b\right )} \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) - 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ) \sin \left (2 \, x\right ) - 2 \, {\left (b \cos \left (2 \, x\right ) + b\right )} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}}}{4 \, b \sin \left (2 \, x\right )}, \frac {4 \, \sqrt {a - b} b \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) \sin \left (2 \, x\right ) - {\left (a - 2 \, b\right )} \sqrt {b} \log \left (\frac {{\left (a - 2 \, b\right )} \cos \left (2 \, x\right ) - 2 \, \sqrt {b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) - a - 2 \, b}{\cos \left (2 \, x\right ) - 1}\right ) \sin \left (2 \, x\right ) - 2 \, {\left (b \cos \left (2 \, x\right ) + b\right )} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}}}{4 \, b \sin \left (2 \, x\right )}, \frac {{\left (a - 2 \, b\right )} \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right ) \sin \left (2 \, x\right ) + \sqrt {-a + b} b \log \left (-{\left (a - b\right )} \cos \left (2 \, x\right ) - \sqrt {-a + b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right ) + b\right ) \sin \left (2 \, x\right ) - {\left (b \cos \left (2 \, x\right ) + b\right )} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}}}{2 \, b \sin \left (2 \, x\right )}, \frac {2 \, \sqrt {a - b} b \arctan \left (-\frac {\sqrt {a - b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{{\left (a - b\right )} \cos \left (2 \, x\right ) + a - b}\right ) \sin \left (2 \, x\right ) + {\left (a - 2 \, b\right )} \sqrt {-b} \arctan \left (\frac {\sqrt {-b} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}} \sin \left (2 \, x\right )}{b \cos \left (2 \, x\right ) + b}\right ) \sin \left (2 \, x\right ) - {\left (b \cos \left (2 \, x\right ) + b\right )} \sqrt {\frac {{\left (a - b\right )} \cos \left (2 \, x\right ) - a - b}{\cos \left (2 \, x\right ) - 1}}}{2 \, b \sin \left (2 \, x\right )}\right ] \]

[In]

integrate(cot(x)^2*(a+b*cot(x)^2)^(1/2),x, algorithm="fricas")

[Out]

[1/4*(2*sqrt(-a + b)*b*log(-(a - b)*cos(2*x) - sqrt(-a + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*si
n(2*x) + b)*sin(2*x) - (a - 2*b)*sqrt(b)*log(((a - 2*b)*cos(2*x) - 2*sqrt(b)*sqrt(((a - b)*cos(2*x) - a - b)/(
cos(2*x) - 1))*sin(2*x) - a - 2*b)/(cos(2*x) - 1))*sin(2*x) - 2*(b*cos(2*x) + b)*sqrt(((a - b)*cos(2*x) - a -
b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/4*(4*sqrt(a - b)*b*arctan(-sqrt(a - b)*sqrt(((a - b)*cos(2*x) - a - b)/(co
s(2*x) - 1))*sin(2*x)/((a - b)*cos(2*x) + a - b))*sin(2*x) - (a - 2*b)*sqrt(b)*log(((a - 2*b)*cos(2*x) - 2*sqr
t(b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x) - a - 2*b)/(cos(2*x) - 1))*sin(2*x) - 2*(b*cos(2
*x) + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/2*((a - 2*b)*sqrt(-b)*arctan(sqrt(-b
)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/(b*cos(2*x) + b))*sin(2*x) + sqrt(-a + b)*b*log(-(a
 - b)*cos(2*x) - sqrt(-a + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x) + b)*sin(2*x) - (b*cos(
2*x) + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1)))/(b*sin(2*x)), 1/2*(2*sqrt(a - b)*b*arctan(-sqrt(a -
 b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/((a - b)*cos(2*x) + a - b))*sin(2*x) + (a - 2*b)*
sqrt(-b)*arctan(sqrt(-b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1))*sin(2*x)/(b*cos(2*x) + b))*sin(2*x) -
 (b*cos(2*x) + b)*sqrt(((a - b)*cos(2*x) - a - b)/(cos(2*x) - 1)))/(b*sin(2*x))]

Sympy [F]

\[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int \sqrt {a + b \cot ^{2}{\left (x \right )}} \cot ^{2}{\left (x \right )}\, dx \]

[In]

integrate(cot(x)**2*(a+b*cot(x)**2)**(1/2),x)

[Out]

Integral(sqrt(a + b*cot(x)**2)*cot(x)**2, x)

Maxima [F]

\[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int { \sqrt {b \cot \left (x\right )^{2} + a} \cot \left (x\right )^{2} \,d x } \]

[In]

integrate(cot(x)^2*(a+b*cot(x)^2)^(1/2),x, algorithm="maxima")

[Out]

integrate(sqrt(b*cot(x)^2 + a)*cot(x)^2, x)

Giac [F(-2)]

Exception generated. \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\text {Exception raised: TypeError} \]

[In]

integrate(cot(x)^2*(a+b*cot(x)^2)^(1/2),x, algorithm="giac")

[Out]

Exception raised: TypeError >> an error occurred running a Giac command:INPUT:sage2:=int(sage0,sageVARx):;OUTP
UT:sym2poly/r2sym(const gen & e,const index_m & i,const vecteur & l) Error: Bad Argument Value

Mupad [F(-1)]

Timed out. \[ \int \cot ^2(x) \sqrt {a+b \cot ^2(x)} \, dx=\int {\mathrm {cot}\left (x\right )}^2\,\sqrt {b\,{\mathrm {cot}\left (x\right )}^2+a} \,d x \]

[In]

int(cot(x)^2*(a + b*cot(x)^2)^(1/2),x)

[Out]

int(cot(x)^2*(a + b*cot(x)^2)^(1/2), x)